﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SqlCon;
using System.Data.SqlClient;

namespace yfxt
{
    public partial class zy_fymx : Form
    {
        public zy_fymx()
        {
            InitializeComponent();
        }

        int Yzxh;
        int ptyz, jzzy, cydy;
        string sql_tj02,sql_brxx;
        DataTable dt_fymx = new DataTable();
        DataTable dt_brxx = new DataTable();


        
        private void zy_fymx_Load(object sender, EventArgs e)
        {
            ptyz=zy_ptyz.int_ptyz;
            jzzy=zy_jzyy.int_jzzy;
            cydy=zy_cydy.int_cydy;
            //zy_ptyz fymx = new zy_ptyz();
            //fymx.get_yzxh += new zy_ptyz.TransferDate(fymx_get_yzxh);
            if (ptyz == 1) Yzxh = zy_ptyz.yzxh;
            if (jzzy == 1) Yzxh = zy_jzyy.yzxh;
            if (cydy == 1) Yzxh = zy_cydy.yzxh;
              
            try 
            {
                sql_brxx = "select b.brxm,c.ypmc,d.mrcs,a.kssj,a.qrrq "+
                "from bq_tj02 a,"+
                "zy_brry b,"+
                "yk_typk c,"+
                "gy_sypc d "+
                "where a.yzxh='"+Yzxh+"' "+
                "and a.zyh=b.zyh "+
                "and a.ypxh=c.ypxh "+
                "and a.sypc=d.pcbm";

                sql_tj02 = "select a.fyrq,a.fysl,a.ypdj,(a.fysl*a.ypdj) as zjje " +
                    "from bq_tj02 a " +
                    "where a.fybz=1 " +
                    "and a.yzxh='" + Yzxh + "' ";
                //try 
                //{
                    dt_brxx.Load(SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction,CommandType.Text,sql_brxx,null));
                    dt_fymx.Load(SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, sql_tj02, null));
                //}
                //catch
                //{
                //    //return;
                //}
                label4.Text = dt_brxx.Rows[0]["brxm"].ToString();
                label5.Text = dt_brxx.Rows[0]["ypmc"].ToString();
                label8.Text = dt_brxx.Rows[0]["mrcs"].ToString();
                label13.Text = dt_brxx.Rows[0]["kssj"].ToString();
                label15.Text = dt_brxx.Rows[0]["qrrq"].ToString();

                dataGridView1.Columns[0].DataPropertyName = dt_fymx.Columns[0].ToString();
                dataGridView1.Columns[1].DataPropertyName = dt_fymx.Columns[1].ToString();
                dataGridView1.Columns[2].DataPropertyName = dt_fymx.Columns[2].ToString();
                dataGridView1.Columns[3].DataPropertyName = dt_fymx.Columns[3].ToString();
                dataGridView1.DataSource = dt_fymx;
            }
            catch//(Exception ex)
            {
                return;
                //MessageBox.Show(ex.ToString());
            }
        }

        //void fymx_get_yzxh(int yzxh)
        //{
        //    Yzxh = yzxh;
        //}
    }
}
